import 'dart:ui' as dartUi;
import 'package:flutter/material.dart';

class UiUtils {

  /// 根据文本配置 获得 Paragraph 段落
  static dartUi.Paragraph getParagraph(String text, double textSize,  {Color color = Colors.white, double itemWidth = 100}) {

    var pb = dartUi.ParagraphBuilder( dartUi.ParagraphStyle(
      textAlign: TextAlign.center,
      fontSize: textSize,
    ));

    pb.addText(text);
    pb.pushStyle(dartUi.TextStyle(color: color));

    var paragraph = pb.build()..layout(dartUi.ParagraphConstraints(width: itemWidth));
    return paragraph;
  }
}